(function () {
	var req, res, writer;

	page = {
		index: function(params) {
			if (params) {
				return params.join(",");
			} else {
				return "Nothing";
			}
		}		
	}

	res = HttpServletResponse({
		getWriter: function(){
			return writer;
		}
	});

	testPage = {
		name: function() {
			return "Page Servlet Test";
		},
		testWithDefault: function() {
			req = HttpServletRequest({
				getRequestURI: function(){
					return "/" }
			});

			var output = ByteArrayOutputStream();
			writer = PrintWriter(output);

			servlets.page.service(req, res);
			writer.flush();

			var expected = page.index();
			var actual = output.toString();
			Assert.assertEquals(expected, actual);
		},
		testWithIndex: function() {
			req = HttpServletRequest({
				getRequestURI: function(){
					return "/index/a/b/c" }
			});

			var output = ByteArrayOutputStream();
			writer = PrintWriter(output);

			servlets.page.service(req, res);
			writer.flush();

			var expected = page.index(['a', 'b', 'c']);
			var actual = output.toString();
			Assert.assertEquals(expected, actual);
		}
	};
}());
